﻿using System;
using System.Collections.Generic;
using DevExpress.XtraEditors;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Helpers;
using AnimalCare.View;
using AnimalCare.Service;


namespace AnimalCare
{
    public partial class frMain : XtraForm
    {
        public frMain()
        {
            InitializeComponent();
            barManager.ForceInitialize();
            SkinHelper.InitSkinPopupMenu(mPaintStyle);
        }

        private void frMain_Load(object sender, EventArgs e)
        {
            gridControl.DataSource = ProductService.search(txtSearch.Text);
        }

        private void tNew_ItemClick(object sender, ItemClickEventArgs e)
        {
            using (FormLogin frLogin = new FormLogin())
            {
                frLogin.ShowDialog();
            }
        }

        private void classificationItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormClassification fc = new FormClassification())
            {
                fc.ShowDialog();
            }
        }

        private void employeeItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormEmployee fe = new FormEmployee())
            {
                fe.ShowDialog();
            }
        }

        private void packagingItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormPakaging fp = new FormPakaging())
            {
                fp.ShowDialog();
            }
        }

        private void positionItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormPosition fp = new FormPosition())
            {
                fp.ShowDialog();
            }
        }

        private void supplierItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormSupplier fs = new FormSupplier())
            {
                fs.ShowDialog();
            }
        }

        private void TypeProductItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormType ft = new FormType())
            {
                ft.ShowDialog();
            }
        }

        private void customerItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormCustomer fc = new FormCustomer())
            {
                fc.ShowDialog();
            }
        }

        private void txtSearch_EditValueChanged(object sender, EventArgs e)
        {
            gridControl.DataSource = ProductService.search(txtSearch.Text);
            gridControl.Refresh();
        }

        private void buyMedicine_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormImportProduct fp = new FormImportProduct())
            {
                fp.ShowDialog();
                gridControl.DataSource = ProductService.search(txtSearch.Text);
                gridControl.Refresh();
            }
        }

        private void saleMedicine_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormSale fs = new FormSale())
            {
                fs.ShowDialog();
                gridControl.DataSource = ProductService.search(txtSearch.Text);
                gridControl.Refresh();
            }
        }

        private void orderItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormSaleStatistics fs = new FormSaleStatistics())
            {
                fs.ShowDialog();
            }
        }

        private void medicineItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            using (FormProductStatistics fp = new FormProductStatistics())
            {
                fp.ShowDialog();
            }
        }
    }
}
